<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改文章分类')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
        
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-articlecategory-edit" th:object="${cmsArticleCategory}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group   col-sm-6">    
                <label class="col-sm-4 control-label is-required">站点编码：</label>
                <div class="col-sm-8">
			         <select name="cmsSiteId" class="form-control m-b required" th:with="categorys=${cmsSiteList}" >
			                 <option value="">所有站点</option>
			                 <option th:each="category : ${categorys}" th:text="${category.title}" th:value="${category.id}" th:field="*{cmsSiteId}"></option>
			         </select>
                </div>
            </div>
            <div class="form-group   col-sm-6">    
                <label class="col-sm-4 control-label is-required">父级编号：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="treeId" name="parentId" type="hidden" th:field="*{parentId}" />
                        <input class="form-control" type="text" onclick="selectArticlecategoryTree()" id="treeName" readonly="true" th:field="*{parentName}" required>
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group col-sm-12">    
                <label class="col-sm-2 control-label is-required">标题：</label>
                <div class="col-sm-10">
                    <input name="title" th:field="*{title}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group   col-sm-6">    
                <label class="col-sm-4 control-label">简称：</label>
                <div class="col-sm-8">
                    <input name="shortTitle" th:field="*{shortTitle}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group   col-sm-6">    
                <label class="col-sm-4 control-label">英文简称：</label>
                <div class="col-sm-8">
                    <input name="enShortTitle" th:field="*{enShortTitle}" class="form-control" type="text">
                </div>
            </div>
            
            
            <div class="form-group   col-sm-12">
                <label class="col-sm-2 control-label  is-required">关键字：</label>
                <div class="col-sm-10">
                    <textarea name="keywords" class="form-control" required>[[*{keywords}]]</textarea>
                </div>
            </div>
            <div class="form-group   col-sm-12">
                <label class="col-sm-2 control-label  is-required">描述：</label>
                <div class="col-sm-10">
                    <textarea name="description" class="form-control" required>[[*{description}]]</textarea>
                </div>
            </div>            
            <div class="form-group   col-sm-6">    
                <label class="col-sm-4 control-label">链接：</label>
                <div class="col-sm-8">
                    <input name="href" th:field="*{href}"  class="form-control"  type="url" >
                </div>
            </div>
            <div class="form-group   col-sm-6">    
                <label class="col-sm-4 control-label">目标：</label>
                <div class="col-sm-8">
                    <input name="target" th:field="*{target}" class="form-control" type="text">
                </div>
            </div>           
            <div class="form-group   col-sm-6">    
                <label class="col-sm-4 control-label">菜单位置：</label>
                <div class="col-sm-8">
                    <select name="dictMenuPosition" class="form-control m-b" th:with="type=${@dict.getType('dict_menu_position')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{dictMenuPosition}"></option>
                    </select>
                </div>
            </div>
            
            
            <div class="form-group   col-sm-6">    
                <label class="col-sm-4 control-label">排序：</label>
                <div class="col-sm-8">
                    <input name="sort" th:field="*{sort}" class="form-control number" type="text" required>
                </div>
            </div>            
            
            <div class="form-group   col-sm-12">    
                <label class="col-sm-2 control-label">封面：</label>
                <div class="col-sm-10">
                    <input type="hidden" name="image" th:field="*{image}">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="image" name="file" type="file">
                    </div>
                </div>
            </div>


            <div class="form-group   col-sm-6">    
                <label class="col-sm-4 control-label">列表视图：</label>
                <div class="col-sm-8">
                    <select name="dictListView" class="form-control m-b" th:with="type=${@dict.getType('dict_list_view')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{dictListView}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group   col-sm-6">    
                <label class="col-sm-4 control-label">内容视图：</label>
                <div class="col-sm-8">
                    <select name="dictContentView" class="form-control m-b" th:with="type=${@dict.getType('dict_content_view')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{dictContentView}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group   col-sm-12">
                <label class="col-sm-2 control-label">备注信息：</label>
                <div class="col-sm-10">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>

    <script th:inline="javascript">
        var prefix = ctx + "ecms/articlecategory";
        $("#form-articlecategory-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-articlecategory-edit').serialize());
            }
        }
        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
        /*文章分类-编辑-选择父文章分类树*/
        function selectArticlecategoryTree() {
            var options = {
                title: '文章分类选择',
                width: "380",
                url: prefix + "/selectArticlecategoryTree/" + $("#treeId").val(),
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = $.modal.getChildFrame(index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            $.modal.close(index);
        }
    </script>
</body>
</html>